package cn.csc.module.member.dal.mysql.rolemenu;

import java.util.*;

import cn.csc.framework.common.pojo.PageResult;
import cn.csc.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.csc.framework.mybatis.core.mapper.BaseMapperX;
import cn.csc.module.member.dal.dataobject.rolemenu.MemberRoleMenuDO;
import org.apache.ibatis.annotations.Mapper;
import cn.csc.module.member.controller.app.rolemenu.vo.*;

/**
 * 角色和菜单关联 Mapper
 *
 * @author liuchuang
 */
@Mapper
public interface MemberRoleMenuMapper extends BaseMapperX<MemberRoleMenuDO> {

    default PageResult<MemberRoleMenuDO> selectPage(AppMemberRoleMenuPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<MemberRoleMenuDO>()
                .eqIfPresent(MemberRoleMenuDO::getRoleId, reqVO.getRoleId())
                .eqIfPresent(MemberRoleMenuDO::getMenuId, reqVO.getMenuId())
                .betweenIfPresent(MemberRoleMenuDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(MemberRoleMenuDO::getId));
    }

    default List<MemberRoleMenuDO> selectList(AppMemberRoleMenuExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<MemberRoleMenuDO>()
                .eqIfPresent(MemberRoleMenuDO::getRoleId, reqVO.getRoleId())
                .eqIfPresent(MemberRoleMenuDO::getMenuId, reqVO.getMenuId())
                .betweenIfPresent(MemberRoleMenuDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(MemberRoleMenuDO::getId));
    }

}
